package com.lovo.service.impl;

import com.lovo.dao.IUserDAO;
import com.lovo.model.UserDO;
import com.lovo.service.IUserService;
import com.lovo.util.MyBatisUtil;
import org.apache.ibatis.session.SqlSession;
import org.springframework.stereotype.Service;
import org.springframework.transaction.annotation.Transactional;

import javax.annotation.Resource;

/**
 * Description:
 *
 * @author LiuChengQi
 * @date Created on 2020/11/14
 */
//注册到ioc容器
@Service
//在要处理事务的方法或类上加@Transactional注解，如果加在类上则表示该类的所有方法都有事务处理。
//设置传播属性的方法：@Transactional(propagation = Propagation.REQUIRED)
@Transactional
public class UserService implements IUserService {
    //@MapperScan(basePackages = "com.lovo.dao")是从这里把实现类注册到容器管理的
    //所以可以直接注入
    @Resource
    private IUserDAO dao ;
    @Override
    public Integer register(UserDO userDO) {
        Integer register = dao.register(userDO);
//        System.out.println(1/0);
        return register;
    }

    @Override
    public UserDO login(String userName, String pwd) {
        UserDO login = dao.login(userName, pwd);
        return login;
    }
}
